package com.csw.foodRecommendation.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.csw.foodRecommendation.entity.User;
import com.csw.foodRecommendation.service.UserService;

@Controller
@RequestMapping("user")
public class UserController {
	@Autowired
	private UserService userService;

	@RequestMapping("login")
	public String login(User user, HttpServletRequest request) {
		User aa = userService.queryByNameAndPassword(user.getName(), user.getPassword());
		if (aa != null) {
			System.out.println("aa;;" + aa);
			request.getSession().setAttribute("user", aa);
			return "redirect:/list/query0";
		} else {
			return "front/login";
		}
	}
}
